package com.leetcode.day7_30;

/**
 * 字符串 A-Z 转数字
 */
public class Code1 {

    public static int titleToNumber(String columnTitle) {
        String sub = columnTitle.substring(0, columnTitle.length());
        System.out.println(sub);
        int num = 0;
        for (int i = 0; i < sub.length(); i++) {
            int value = (int)sub.charAt(i) - 64;
            num = num * 26 + value;
        }
        return num;
    }

    public static void main(String[] args) {
        String s = "A";
        System.out.println(titleToNumber(s));
    }
}
